
<html>
<head>
<title>Twitter Twitter API w\ JSON</title>
<script src="http://www.google.com/jsapi"></script>
<script>
// Load jQuery
google.load("jquery", "1.3");
</script>

<script>
	var myTweets2 = new Object();
	myTweets2.id= 1;
	myTweets2.result = "GREAT";
	myTweets2.text = "text";

	var myTweetsResult = new Object();
	myTweetsResult.id= 1;
	myTweetsResult.result = "GREAT";
	myTweetsResult.text = "text";

	var myLocation = new Object();
	myLocation.id= 1;
	myLocation.lantitude = "GREAT";
	myLocation.longtitude = "text";
	myLocation.phonenumber = "13910141540";
	
	var myLocationResult = new Object();
	myTweetsResult.id= 1;
	myTweetsResult.resultcode = "0";
	myTweetsResult.resulttext = "successful";
	
function getJSON(){
  //Get the JSON string and pass it to the cb function
  //$.get("twitter.php", function(data){cb(data)});
	
	serialData2 = JSON.stringify(myTweets2);
    $.ajax({
           type: "get",
           url: "<?php echo $this->baseUrl; ?>/mobile/reportlocation",
           data: "myloc="+serialData2,
           success:function(data){
                 cb(data);
           },
           async: false
        });
}


function cb(data){
    //converts the JSON string to a JavaScript object
    alert(data);
    eval("myTweets="+data); 
    myTweetsResult = myTweets;
    //document.getElementById("content123").value = myTweets.user.name + " says:<br/>\"" + myTweets.text + "\"";
    document.getElementById("content123").value = myTweetsResult.id + " says:" + myTweetsResult.result;
    //document.write();

}
function onClick(){	
	  myTweets2.text = document.getElementById("content123").value;
    //implements the JSON.org parser

    mySerializedTweets = JSON.stringify(myTweets2);

    alert(mySerializedTweets);
    var submit = 1;
    $.post("<?php echo $this->baseUrl; ?>/mobile/reportlocation",{page:submit,myloc:mySerializedTweets},function(sData){
    	alert(sData);		
    });
}

function onSubmitLocation(){	
	myLocation.lantitude = document.getElementById("latitude").value;
	myLocation.longtitude = document.getElementById("longtitude").value;
	myLocation.phonenumber = document.getElementById("phonenumber").value;
		//implements the JSON.org parser
	myLocation.text = "a";
	mySerializedTweets = JSON.stringify(myLocation);

    alert(mySerializedTweets);
	var submit = 1;
	$.post("<?php echo $this->baseUrl; ?>/mobile/reportme",{page:submit,myloc:mySerializedTweets},function(sData){
		 //eval("myTweets="+sData); 
		 //myTweetsResult = myTweets;		
		 alert(sData);
	});
}
</script>
</head>
<body>
	
	
	
	lantitude:<input type="text" id="latitude" size="20" />
	longtitude:<input type="text" id="longtitude" size="20" />
	phone number:<input type="text" id="phonenumber" size="20" />
	<input type="button" onClick="javascript:onSubmitLocation();" value="submit" />
	<br>
	<input type="text" id="content123" size="160" onClick="javascript:getJSON();"/>
	<input type="button" onClick="javascript:onClick();" value="hahaha" />
</body>
</html>
